package com.wcbdota.util;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.util.Log;

public class UpdateApp {
	private static String TAG = UpdateApp.class.getSimpleName();

	// 获取apk的VesionName，即AndroidManifest.xml中定义的android:versionName
	public String getVesionName(Context context) {
		String versionName = null;
		try {
			versionName = context.getPackageManager().getPackageInfo(
					"net.vpntunnel", 0).versionName;
		} catch (NameNotFoundException e) {
			Log.e(TAG, e.getMessage());
		}
		return versionName;
	}

	// 获取apk的versionCode，即AndroidManifest.xml中定义的android:versionCode
	public int getVersionCode(Context context) {
		int versionCode = 0;
		try {
			versionCode = context.getPackageManager().getPackageInfo(
					"net.vpntunnel", 0).versionCode;
		} catch (NameNotFoundException e) {
			Log.e(TAG, e.getMessage());
		}
		return versionCode;
	}
}
